package cn.smbms.service.provider;

import cn.smbms.dao.provider.ProviderMapper;
import cn.smbms.pojo.Provide;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service("providerService")
public class ProviderServiceImpl implements ProviderService {

    public void setProviderMapper(ProviderMapper providerMapper) {
        this.providerMapper = providerMapper;
    }

    public ProviderMapper getProviderMapper(){return providerMapper;}

    @Autowired
    private ProviderMapper providerMapper;

    @Override
    public List<Provide> findUsersWithConditions(Provide provide) {
        try {
            return providerMapper.list(provide);  //调用DAO方法进行查询
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public List<Provide> likeproName(Provide provide) {
        return providerMapper.likeproName(provide);
    }



  /*@Override
    public boolean add(Provide provide) {
        boolean result = false;
        try {
            if (providerMapper.add(provide) == 1)
                result = true;
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
        return result;
    }*/

    public int add(Provide provide) {

        return providerMapper.add(provide);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public int update(Provide provide) {
        return providerMapper.update(provide);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public int del(Provide provide) {
        return providerMapper.del(provide);
    }

}
